package com.jhgk.jhcee.oauth.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jhgk.jhcee.common.resultful.BasisResultful;
import com.jhgk.jhcee.data.authorization.entity.SysUserInfo;
import com.jhgk.jhcee.data.authorization.mapper.SysUserInfoMapper;
import com.jhgk.jhcee.oauth.domain.dao.SysUserInfoDao;
import com.jhgk.jhcee.oauth.domain.model.SysUserInfoModel;
import com.jhgk.jhcee.oauth.service.SysUserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Description:
 * @Author: lemon_xzp
 * @Date: 2021/10/20 23:55
 */
@Service
public class SysUserInfoServiceImpl implements SysUserInfoService {

    @Autowired
    SysUserInfoMapper sysUserInfoMapper;

    @Autowired
    SysUserInfoDao sysUserInfoDao;

    @Override
    public BasisResultful<SysUserInfo> searchByAccount(String account) {
        QueryWrapper<SysUserInfo> wrapper = new QueryWrapper<>();
        wrapper.eq("account", account);
        wrapper.eq("is_valid", 1);
        SysUserInfo sysUserInfo = sysUserInfoMapper.selectOne(wrapper);
        return null == sysUserInfo ? BasisResultful.fail() : BasisResultful.success(sysUserInfo);
    }

    @Override
    public BasisResultful<SysUserInfoModel> searchUserClient(String account) {
        SysUserInfoModel sysUserInfoModel = sysUserInfoDao.searchUserClient(account);
        return null == sysUserInfoModel ? BasisResultful.fail() : BasisResultful.success(sysUserInfoModel);
    }
}
